package com.bestescortbedsystem.controller.message;

 import com.bestescortbedsystem.entity.SesUserSharingMessage;
 import com.bestescortbedsystem.service.MessageService;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;

 import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;

@RestController
@RequestMapping("message")
public class MessageController {
    @Resource
    private MessageService messageService;
    /*
    * 获取所有消息
    * @param messagetype 查询条件： 消息类型
    * @return
    * */
    @RequestMapping("list")
    public Map<String,Object> list(String userType,String messagetype,String pageNumber, String pageSize){
        Map<String,Object> map=new HashMap<>();
        pageSize="2";
        try{
            map=messageService.getAllMessage(userType,messagetype,pageNumber,pageSize);
            map.put("result",true);
        }catch (Exception e){
            map.put("result",false);
        }finally {
            return map;
        }
    }
    /*
    * 删除消息
    * @param messageid 通过主键删除
    * @return
    * */
    @RequestMapping("delete")
    public Map<String,Object> delete(String messageid){
        Map<String,Object> map=new HashMap<>();
        try{
            messageService.deleteMessage(messageid);
            map.put("result",true);
        }catch (Exception e){
            map.put("result",false);
        }finally {
            return map;
        }
    }

    /*
    * 新增消息
    * */
    @RequestMapping("add")
    public Map<String,Object> addMessage(String userType,String messagetype,Integer messagesendtype,String messagetitle,String messagecontent){
        Map<String,Object> map=new HashMap<>();
        try{
            messageService.addMessage(userType,messagetype,messagesendtype,messagetitle,messagecontent);
            map.put("result",true);
        }catch (Exception e){
            map.put("result",false);
        }finally {
            return map;
        }
    }


}
